<template>
  <view class="tabBar">
    <view v-for="(item,index) in tabList" class="item" @click="to(item,index)">
      <image :src="tabIndex==index?item.selectedIconPath:item.iconPath"></image>
      <view class="title" :class="{active:tabIndex==index}">{{ item.text }}</view>
    </view>

  </view>

</template>
<script>
export default {
  name: "TabBar",
  props: {
    tabIndex: {
      default: 0
    }
  },
  data() {
    return {
      show:true,
      tabList: [
        {
          "text": "首页",
          "pagePath": "/pages/index/index",
          "iconPath": "/static/tabbar/index.png",
          "selectedIconPath": "/static/tabbar/index_action.png"
        },
        {
          "text": "助手",
          "pagePath": "/pages/whotel/whotel",
          "iconPath": "/static/tabbar/write.png",
          "selectedIconPath": "/static/tabbar/write_action.png"
        },
        {
          "text": "",
          "pagePath": "/pages/qrCode/qrCode",
          "iconPath": "/static/tabbar/logo.png",
          "selectedIconPath": "/static/tabbar/logo.png"
        },
        {
          "text": "风物",
          "pagePath": "/pages/goods/goods",
          "iconPath": "/static/tabbar/gift.png",
          "selectedIconPath": "/static/tabbar/gift_action.png"
        },
        {
          "text": "我的",
          "pagePath": "/pages/me/me",
          "iconPath": "/static/tabbar/me.png",
          "selectedIconPath": "/static/tabbar/me_action.png"
        }
      ]
    };
  },
  methods: {
    to(item, index) {
      uni.switchTab({
        url: item.pagePath,

      })

    }
  }
}
</script>
<style scoped lang="scss">
.tabBar {
  z-index: 99999;
  background-color: white;
  font-size: 26rpx !important;
  padding-top: 10rpx;
  font-weight: normal;
  color: gray;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  border-top: 1px solid #f2f2f2;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: calc(20rpx + env(safe-area-inset-bottom));

  .item {
    image {
      width: 80rpx;
      height: 80rpx;
      display: block;
      margin: auto;
    }

    .title {
      text-align: center;
    }

    .active {
      color: black;
    }
  }
}
</style>